﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace getPixelInformation
{
    public partial class getPixelInformation : Form
    {
        private Pixels P;
        public getPixelInformation()
        {
            InitializeComponent();
            this.P = new Pixels();
        }

        private void btBrowse_Click(object sender, EventArgs e)
        {
            OpenFileDialog oFD = new OpenFileDialog();
            oFD.Title = "Select a Bitmap file";
            oFD.InitialDirectory = Application.ExecutablePath;
            oFD.Filter = "Image Files (*.bmp) | *.bmp";
            oFD.FilterIndex = 2;
            oFD.FileName = "sample.bmp";
            if (oFD.ShowDialog() == DialogResult.OK)
            {
                tbPath.Text = oFD.FileName;
                this.P.getPixelInformation(oFD.FileName.ToString());
            }

        }

        private void btSave_Click(object sender, EventArgs e)
        {
            SaveFileDialog sFD = new SaveFileDialog();
            sFD.Title = "Save Directory";
            sFD.InitialDirectory = Application.ExecutablePath;
            sFD.Filter = "Text Files (*.txt) | *.txt";
            sFD.FileName = "Choosen";
            if (sFD.ShowDialog() == DialogResult.OK)
            {
                string str = Path.GetDirectoryName(sFD.FileName);
                bool result = this.P.writePixelInFormation(str + "\\r.txt", str +"\\g.txt", str + "\\b.txt", str + "\\gs.txt");
                if (result == true)
                {
                    MessageBox.Show("This proccess is ok");
                }
                else
                {
                    MessageBox.Show("This proccess is false");
                }
            }
        }
    }
}
